package reduce.fz.com.reduce.custom;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import reduce.fz.com.reduce.R;

import static reduce.fz.com.reduce.R.drawable.notify_red_circle;

/**
 * Created by qingshengzheng on 15/8/27.
 */
public class SanItem extends RelativeLayout {
    private ImageView mleftImage;
    private TextView tvitemTitle;
    private ImageView mrightImage;
    private TextView mNotifyCircle;

    public SanItem(Context context) {
        super(context);
        View view = LayoutInflater.from(this.getContext()).inflate(R.layout.custom_san_item, null);
        initWidget(view);
        this.addView(view);

    }

    public SanItem(Context context, AttributeSet attrs) {
        super(context, attrs);
        View view = LayoutInflater.from(this.getContext()).inflate(R.layout.custom_san_item, null);
        initWidget(view);
        this.addView(view);
    }


    public void initWidget(View view) {
        mleftImage = (ImageView) view.findViewById(R.id.iv_left);
        tvitemTitle = (TextView) view.findViewById(R.id.tv_title);
        mrightImage = (ImageView) view.findViewById(R.id.iv_right);
        mNotifyCircle=(TextView) view.findViewById(R.id.notify_circle);
    }

    public void setContent(int leftImageRid, String itemTitle, int rightImageRid) {
        mleftImage.setImageResource(leftImageRid);
        mrightImage.setImageResource(rightImageRid);
        tvitemTitle.setText(itemTitle);
    }

    public void setNotifyIcon(int num)
    {
        mNotifyCircle.setVisibility(VISIBLE);
        mNotifyCircle.setText(num+"");
    }


    /*private  TextView getCircleNumView(int num)
    {
        TextView textView=new TextView(this.getContext());
        RelativeLayout.LayoutParams lp=new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        lp.setMargins(10,0,0,0);
        textView.setLayoutParams(lp);
        textView.setTextColor(getResources().getColor(R.color.white));
        textView.setTextSize(getResources().getDimensionPixelSize(R.dimen.activity_padding_top));
        textView.setBackgroundResource(R.drawable.notify_red_circle);
        return textView;

    }*/



}
